package com.da.javatest.niuke.jianzhi;

/**
 * @author chenlida
 * @date 2020/10/20 16:46
 * https://www.nowcoder.com/practice/c6c7742f5ba7442aada113136ddea0c3?
 * tpId=13&tags=&title=&diffculty=0&judgeStatus=0&rp=1
 */
public class C7Solution {
    public static int Fibonacci(int n) {
        if (n < 2) {
            return n;
        }
        int pre = 1;
        int now = 1;
        for (int i = 2; i < n; i++) {
            int temp = now + pre;
            pre = now;
            now = temp;
        }
        return now;
    }

    // 0 1 1 2 3 5 8 13
    public static void main(String[] args) {
        System.out.println(Fibonacci(7));
    }

}
